local wujinfenyan = fk.CreateSkill {

  name = "wujinfenyan",

  tags = { Skill.Compulsory, },

}

Fk:loadTranslationTable{
    ["wujinfenyan"] = "无烬",
    [":wujinfenyan"] = "首次进入濒死状态时，你可以将体力回到1点，并且直到你的回合开始你都不能成为牌的目标。触发后你造成的伤害永久+1。",

    ["@wujin_target"] = "无烬状态",
}

wujinfenyan:addEffect("prohibit", {
  name = "wujinfenyan",
  frequency = Skill.Compulsory,
  is_prohibited = function(self, from, to, card)
    if to:hasSkill(self.name) and to:getMark("@wujin_target") > 0 then
      return true
    end
  end,
})


wujinfenyan:addEffect(fk.EnterDying, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self.name) and 
      player:usedSkillTimes(self.name, Player.HistoryGame) == 0 and
      player.maxHp > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:isWounded() then
      room:recover { 
        num = 1 - player.hp, 
        skillName = wujinfenyan.name, 
        who = player, 
        recoverBy = player 
      }
    end
    
    if player.dead then return end
    room:setPlayerMark(target, "@wujin_target", 1)
    room:addPlayerMark(player, "#@wujinjiashang_" , 1)
  end,
})

wujinfenyan:addEffect(fk.DamageInflicted,{
    can_trigger = function(self,event,target,player,data)
        local sha = data.from
        return sha == player
        and player:getMark("#@wujinjiashang_",player) > 0
    end,
    on_use = function(self,event,target,player,data)
        local room = player.room
        data:changeDamage(1)
    end,
})

wujinfenyan:addEffect(fk.TurnStart,{
    can_trigger = function(self,event,target,player)
        return target == player
        and player:getMark("@wujin_target",player) > 0
    end,
    on_use = function(self,event,target,player)
        local room = player.room
        room:setPlayerMark(player,"@wujin_target",0)
    end,
})

return wujinfenyan